home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / coffee.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  3.1 KB  |  92 lines

  1. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  2. ; At ECS Dept, University of Southampton, England.
  3.  
  4. ; This program is free software: you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 3 of the License, or
  7. ; (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16.  
  17.  
  18. (define (script-fu-coffee-stain inImage inLayer inNumber inDark)
  19.   (let* (
  20.         (theImage inImage)
  21.         (theHeight (car (gimp-image-height theImage)))
  22.         (theWidth (car (gimp-image-width theImage)))
  23.         (theNumber inNumber)
  24.         (theSize (min theWidth theHeight))
  25.         (theStain 0)
  26.         )
  27.  
  28.     (gimp-context-push)
  29.  
  30.     (gimp-image-undo-group-start theImage)
  31.  
  32.     (while (> theNumber 0)
  33.       (set! theNumber (- theNumber 1))
  34.       (set! theStain (car (gimp-layer-new theImage theSize theSize
  35.                                           RGBA-IMAGE "Stain" 100
  36.                                           (if (= inDark TRUE)
  37.                                               DARKEN-ONLY-MODE NORMAL-MODE))))
  38.  
  39.       (gimp-image-add-layer theImage theStain 0)
  40.       (gimp-selection-all theImage)
  41.       (gimp-edit-clear theStain)
  42.  
  43.       (let ((blobSize (/ (rand (- theSize 40)) (+ (rand 3) 1))))
  44.         (gimp-ellipse-select theImage
  45.                              (/ (- theSize blobSize) 2)
  46.                              (/ (- theSize blobSize) 2)
  47.                              blobSize blobSize CHANNEL-OP-REPLACE TRUE 0 FALSE)
  48.       )
  49.  
  50.       (script-fu-distress-selection theImage theStain
  51.                                     (* (+ (rand 15) 1) (+ (rand 15) 1))
  52.                                     (/ theSize 25) 4 2 TRUE TRUE)
  53.  
  54.       (gimp-context-set-gradient "Coffee")
  55.  
  56.       (gimp-edit-blend theStain CUSTOM-MODE NORMAL-MODE
  57.                        GRADIENT-SHAPEBURST-DIMPLED 100 0 REPEAT-NONE FALSE
  58.                        FALSE 0 0 TRUE
  59.                        0 0 0 0)
  60.  
  61.       (gimp-layer-set-offsets theStain
  62.                               (- (rand theWidth) (/ theSize 2))
  63.                               (- (rand theHeight) (/ theSize 2)))
  64.     )
  65.  
  66.     (gimp-selection-none theImage)
  67.  
  68.     (gimp-image-undo-group-end theImage)
  69.  
  70.     (gimp-displays-flush)
  71.  
  72.     (gimp-context-pop)
  73.   )
  74. )
  75.  
  76. ; Register the function with GIMP:
  77.  
  78. (script-fu-register "script-fu-coffee-stain"
  79.   _"_Coffee Stain..."
  80.   _"Add realistic looking coffee stains to the image"
  81.   "Chris Gutteridge"
  82.   "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  83.   "25th April 1998"
  84.   "RGB*"
  85.   SF-IMAGE       "The image"   0
  86.   SF-DRAWABLE    "The layer"   0
  87.   SF-ADJUSTMENT _"Stains"      '(3 1 10 1 1 0 0)
  88.   SF-TOGGLE     _"Darken only" TRUE
  89. )
  90.  
  91. (script-fu-menu-register "script-fu-coffee-stain" "<Image>/Filters/Decor")
  92.